<div class="am-fr">
  <ul class="am-pagination">
  <!-- 处理第一页 -->
  	<li><a href="${pageUrl}?pageNum=1">首页</a></li>
    <%if(list.pageNum <= 1){%>
    <li class="am-disabled"><a href="#">«</a></li>
    <%}else{%>
     <li><a href="${pageUrl}?pageNum=${list.pageNum-1}">«</a></li>
    <%}%>
   
   <%
   // 开始位置(循环)
   var beginIndex = 0;
    // 结束位置(循环)
   var endIndex = 0;
   
   if(list.pageNum > 2){
   	beginIndex = list.pageNum -2;
   	
   	
     if(list.pageNum < list.totalPage){
     		if(list.pageNum == list.totalPage -1){
     			endIndex = list.totalPage;
     			beginIndex = beginIndex - 1;
     		}else{
           	endIndex = list.pageNum + 2;
          }
   	}            	
   	else{
   	    endIndex = list.totalPage;
   	    beginIndex = beginIndex - 2 ;
   	}
   	
   }else{
   	beginIndex = 1;
   	endIndex = 5;                 	
   }
                    
   if(list.totalPage < 5){
   		beginIndex = 1;
  		endIndex = list.totalPage;
   }

   %>
   
   <%
   	for(var index = beginIndex;index<=endIndex;index++){
   %> 
   <li class="${list.pageNum== index?'am-active':''}"><a href="${pageUrl}?pageNum=${index}">${index}</a></li>
   <%}%>          
    
    <!-- 处理最后一页 -->
    <%if(list.pageNum >= list.totalPage){%>
    <li class="am-disabled"><a href="#">»</a></li>
    <%}else{%>
     <li><a href="${pageUrl}?pageNum=${list.pageNum+1}">»</a></li>
     <li><a href="${pageUrl}?pageNum=${list.totalPage}">尾页</a></li>
    <%}%>  
      
  </ul>
</div>